package main

import (
	"fmt"
	"github.com/pkg/errors"
	"github.com/sirupsen/logrus"
	"strings"
	"time"
)

type CustomFormatter struct{}

func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error) {

	output := fmt.Sprintf("%s [%s] %s\n", entry.Time.Format(time.RFC3339), strings.ToUpper(entry.Level.String()), entry.Message)
	if err, ok := entry.Data[logrus.ErrorKey].(error); ok {
		output += fmt.Sprintf("%+v\n", err)
	}

	return []byte(output), nil
}

func main() {

	logrus.SetFormatter(new(CustomFormatter))
	err := errors.Wrap(errors.New("this is an error"), "error occurred")
	if err != nil {
		logrus.Errorf("somethings wrong: %+v", err)
	}
}
